﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Data;
using System.Globalization;
using System.Xml;
using System.Xml.Linq;
using System.IO;
using System.Windows.Media.Animation;


namespace WPFStudy
{

    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    internal partial class MainWindow : Window
    {
        private double o = 1.0;
        public MainWindow()
        {
            InitializeComponent();
        }

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            PathGeometry pg = this.layoutRoot.FindResource("movingPath") as PathGeometry;
            Duration duration = new Duration(TimeSpan.FromMilliseconds(600));

            //创建动画
            DoubleAnimationUsingPath dapX = new DoubleAnimationUsingPath();
            dapX.PathGeometry = pg;
            dapX.Source = PathAnimationSource.X;
            dapX.Duration = duration;

            DoubleAnimationUsingPath dapY = new DoubleAnimationUsingPath();
            dapY.PathGeometry = pg;
            dapY.Source = PathAnimationSource.Y;
            dapY.Duration = duration;

            dapX.AutoReverse = true;
            dapY.AutoReverse = true;
            dapX.RepeatBehavior=RepeatBehavior.Forever;
            dapY.RepeatBehavior = RepeatBehavior.Forever;

            this.tt.BeginAnimation(TranslateTransform.XProperty,dapX);
            this.tt.BeginAnimation(TranslateTransform.YProperty, dapY);


        }
    }


}
